package zhishuang.wang.sansi.playlist.entry;

/**
 * @Author Zhishuang.Wang
 * @Date 2023/7/5 11:08
 * @Email 1406110602@qq.com
 */
import zhishuang.wang.sansi.tools.ReturnData;

public class AreaPositon {
    private Integer x;
    private Integer y;
    private Integer height;
    private Integer width;
    private Integer areaIndex;

    public AreaPositon(int x, int y, int height, int width, int areaIndex) {
        this.x = x;
        this.y = y;
        this.height = height;
        this.width = width;
        this.areaIndex = areaIndex;
    }

    public ReturnData checkParam() {
        ReturnData rd = new ReturnData();
        rd.setCode(1);
        String errorMes = "";
        if (this.x == null) {
            errorMes = errorMes + "起点x坐标必填；";
        }

        if (this.y == null) {
            errorMes = errorMes + "起点y坐标必填；";
        }

        if (this.height == null) {
            errorMes = errorMes + "区域高度必填；";
        } else if (this.height < 0) {
            errorMes = errorMes + "区域高度必须大于0；";
        }

        if (this.width == null) {
            errorMes = errorMes + "区域宽度必填；";
        } else if (this.width < 0) {
            errorMes = errorMes + "区域宽度必须大于0；";
        }

        if (this.areaIndex == null) {
            errorMes = errorMes + "区域序号必填；";
        } else if (this.areaIndex < 0 || this.areaIndex > 65535) {
            errorMes = errorMes + "区域序号取值范围：0-65535；";
        }

        if (errorMes != null && errorMes.length() != 0) {
            rd.setMessage(errorMes);
        } else {
            rd.setCode(0);
        }

        return rd;
    }

    public Integer getX() {
        return this.x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return this.y;
    }

    public void setY(Integer y) {
        this.y = y;
    }

    public Integer getHeight() {
        return this.height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }

    public Integer getWidth() {
        return this.width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getAreaIndex() {
        return this.areaIndex;
    }

    public void setAreaIndex(Integer areaIndex) {
        this.areaIndex = areaIndex;
    }
}

